<?php

if (!defined('BASEPATH'))
    exit('No direct script access allowed');

/*
 * checks if user is logged in. 
 * if not then displays login page
 */
if (!function_exists('check_user_login')) {
    function check_user_login() {
        $CI =& get_instance();
        if(! $CI->session->userdata('is_logged_in'))
			 redirect('login');
    }	
}
/**
 * Redirect to previous page if http referer is set. Otherwise to server root.
 */
 
if (!function_exists('generateRedirectURL'))
{
    function generateRedirectURL()
    {	
		$CI =& get_instance();
        $preURL = parse_url($_SERVER['REQUEST_URI']);
		$redirectUrl = array('redirectUrl' => 'http://' . $_SERVER['SERVER_NAME'] . $preURL['path']);
		$CI->session->set_userdata($redirectUrl);
		
    }
}

?>